<!-- 质讯管理 -->
<template>
  <div class="myteam_contaniner">
    <van-pull-refresh v-model="isLoading" @refresh="onRefresh" style="height:calc(100vh - 46px);overflow: auto;">
      <van-list v-model="loading" :finished="finished" finished-text="我是有底线的" @load="onLoad" :immediate-check="false" :offset="10">
        <div class="content">
          <div class="list" v-for="item in getList" :key="item.id">
            <div @click="$router.push(`/newslist?id=${item.id}`)">
              <van-row>
                <van-col span="14">
                  <div>
                    <p class="title">{{item.title}}</p>
                    <p class="gray">{{common.formatDate(item.addTime)}}</p>
                  </div>
                </van-col>
                <van-col span="10">
                  <div class="img-box">
                    <img :src="item.picUrl" alt="">
                  </div>
                </van-col>
              </van-row>
            </div>
          </div>
        </div>
      </van-list>
    </van-pull-refresh>
  </div>
</template>

<script>
export default {
  data () {
    return {
      data: {
        pageSize: 10,
        currentPage: 1,
        type: '4'
      },
      isLoading: false,
      finished: false,  //是否加载完所有数据
      loading: false,  //是否加载完所有数据
      getList: [],
    };
  },
  methods: {
    onLoad () {      //上拉加载
      setTimeout(() => {
        this.getMyTeam()
        this.loading = true
        this.data.currentPage++
      }, 500)
    },
    onRefresh () {
      setTimeout(() => {
        this.isLoading = false;
        this.loading = false
        this.finished = false
        this.data.currentPage = 1;
        this.getList = []
        this.getMyTeam()
        this.$toast('刷新成功');
      }, 500);
    },
    //获取资讯列表
    async getMyTeam () {
      let url = '/article/queryPage'
      let result = await this.request.mobileRequest('POST', url, this.data)
      if (result.code == 200) {
        this.loading = false
        if (this.data.currentPage === 1) {
          this.getList = result.data.datas
          console.log(this.getList)
        } else {
          if (result.data.datas != '' && this.data.currentPage > 1) {
            this.getList = this.getList.concat(result.data.datas)
            console.log(3333)
          }
        }
        if (result.data.datas.length < this.data.pageSize) {
          this.finished = true
        }
      } else {
        this.$notify({ type: 'warning', message: result.msg });
      }
    }
  },
  mounted () {
    this.getMyTeam();
  }
};
</script>

<style scoped>
.content {
}
.list {
  height: 1.8rem;
  padding: 0.2rem;
  background: #fff;
  border-bottom: 0.02rem solid #d9d9d9;
}
.title {
  height: 1rem;
  font-size: 0.38rem;
  padding-top: 0.2rem;
  width: 90%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.img-box {
  height: 1.6rem;
  width: 3rem;
  padding-top: 0.1rem;
  margin: auto;
}
.img-box img {
  width: 100%;
  height: 100%;
  border-radius: 5px;
}
</style>
